extends Node2D

@export var ENEMY : PackedScene = null
@export var spawnAnimationScene : PackedScene = null
var current_enemy = null
var is_creating := false

func _process(delta: float) -> void:
	if (current_enemy == null && !is_creating):
		create_enemy()

func create_enemy():
	is_creating = true
	var spawn_animation := spawnAnimationScene.instantiate()
	spawn_animation.global_position = global_position
	spawn_animation.finished.connect(after_finished)
	get_parent().add_child(spawn_animation)

func after_finished():
	var new_enemy := ENEMY.instantiate()
	new_enemy.global_position = global_position
	get_parent().add_child(new_enemy)
	current_enemy = new_enemy
	is_creating = false
